package com.cdeledu.thread4.c15;

import java.util.concurrent.TimeUnit;

public class Test {

	public static void main(String[] args) {
		final TaskLifecycle<String> lifecycle = new TaskLifecycle.EmptyLifecycle<String>() {
			public void onFinish(Thread thread, String result) {
				System.out.println("The result is " + result);
			}
		};
		Observable observableThread = new ObservableThread<>(lifecycle, () -> {
			try {
				TimeUnit.SECONDS.sleep(2);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(" finished done.");
			return "Hello Observer";
		});
		observableThread.start();
	}

}
